package com.youku.plugins.controlbarV4
{
   import com.youku.interfaces.IPlugin;
   import com.youku.plugins.controlbarV4.model.PreviewDataProxy;
   import com.youku.plugins.PluginEventDispather;
   import flash.display.MovieClip;
   import com.youku.interfaces.IPlayerProxy;
   import com.youku.plugins.controlbarV4.view.ControlBarMediator;
   import com.youku.plugins.controlbarV4.view.PreviewerMediator;
   import com.youku.plugins.controlbarV4.view.ProgressBarMediator;
   import com.youku.plugins.controlbarV4.view.events.ControlBarEvent;
   import com.youku.plugins.controlbarV4.view.interfaces.IControlBar;
   import com.youku.plugins.controlbarV4.view.components.ProgressBar;
   import flash.net.registerClassAlias;
   
   public class ControlBarFacade extends Object implements IPlugin
   {
      
      public function ControlBarFacade() {
         super();
      }
      
      private static var _instance:ControlBarFacade;
      
      public static function getInstance() : ControlBarFacade {
         if(_instance == null)
         {
            _instance = new ControlBarFacade();
         }
         return _instance as ControlBarFacade;
      }
      
      private var _previewDataProxy:PreviewDataProxy;
      
      private var _pluginEventDispather:PluginEventDispather;
      
      private var _font:ControlBarFont;
      
      private var _mainMc:MovieClip;
      
      private var _playerProxy:IPlayerProxy;
      
      private var _barMediator:ControlBarMediator;
      
      private var _previewerMediator:PreviewerMediator;
      
      private var _progressbarMediator:ProgressBarMediator;
      
      public function init(param1:MovieClip, param2:IPlayerProxy) : void {
         this.initAsset();
         this._mainMc = param1;
         this._playerProxy = param2;
         this._font = new ControlBarFont();
         this._pluginEventDispather = PluginEventDispather.getInstance();
         this._pluginEventDispather.addEventListener(ControlBarEvent.SHOW_PREVIEWER,this.controlBarEvent);
         this._previewDataProxy = new PreviewDataProxy(param2);
         this.initControlBar();
      }
      
      private function controlBarEvent(param1:ControlBarEvent) : void {
         var _loc2_:Number = param1.data.time;
         var _loc3_:String = this._previewDataProxy.getPreviewURL(_loc2_);
         this._pluginEventDispather.dispatchEvent(new ControlBarEvent(ControlBarEvent.SHOW_PREVIEWER_VIDEO));
         this._pluginEventDispather.dispatchEvent(new ControlBarEvent(ControlBarEvent.SET_PREVIEW_URL,
            {
               "url":_loc3_,
               "time":_loc2_
            }));
      }
      
      private function initControlBar() : void {
         this._barMediator = new ControlBarMediator(this._mainMc,this._playerProxy,this._pluginEventDispather);
         this._barMediator.init();
         var _loc1_:IControlBar = this._barMediator.getViewComponent() as IControlBar;
         this._previewerMediator = new PreviewerMediator((_loc1_.progressbar as ProgressBar).previewer,this._playerProxy,this._pluginEventDispather);
         this._progressbarMediator = new ProgressBarMediator(_loc1_.progressbar as ProgressBar,this._playerProxy,this._pluginEventDispather);
         this._progressbarMediator.init();
      }
      
      private function initAsset() : void {
         registerClassAlias("C4_Play_animation",C4_Play_animation);
         registerClassAlias("C_FullScreen_disable_f",C4_FullScreen_disable_f);
         registerClassAlias("C_FullScreen_disable",C4_FullScreen_disable);
         registerClassAlias("C_FullScreen_down",C4_FullScreen_down);
         registerClassAlias("C_FullScreen_over",C4_FullScreen_over);
         registerClassAlias("C_FullScreen_up",C4_FullScreen_up);
         registerClassAlias("C_NonfullScreen_disable_f",C4_NonfullScreen_disable_f);
         registerClassAlias("C_NonfullScreen_disable",C4_NonfullScreen_disable);
         registerClassAlias("C_NonfullScreen_down",C4_NonfullScreen_down);
         registerClassAlias("C_NonfullScreen_over",C4_NonfullScreen_over);
         registerClassAlias("C_NonfullScreen_up",C4_NonfullScreen_up);
         registerClassAlias("C_Next_disable_f",C4_Next_disable_f);
         registerClassAlias("C_Next_disable",C4_Next_disable);
         registerClassAlias("C_Next_down",C4_Next_down);
         registerClassAlias("C_Next_over",C4_Next_over);
         registerClassAlias("C_Next_up",C4_Next_up);
         registerClassAlias("C_Pause_disable_f",C4_Pause_disable_f);
         registerClassAlias("C_Pause_disable",C4_Pause_disable);
         registerClassAlias("C_Pause_down",C4_Pause_down);
         registerClassAlias("C_Pause_over",C4_Pause_over);
         registerClassAlias("C_Pause_up",C4_Pause_up);
         registerClassAlias("C_Play_disable_f",C4_Play_disable_f);
         registerClassAlias("C_Play_disable",C4_Play_disable);
         registerClassAlias("C_Play_down",C4_Play_down);
         registerClassAlias("C_Play_over",C4_Play_over);
         registerClassAlias("C_Play_up",C4_Play_up);
         registerClassAlias("C_Text_btn_bg_up",C_Text_btn_bg_up);
         registerClassAlias("C_Text_btn_bg_over",C_Text_btn_bg_over);
         registerClassAlias("C_Text_btn_bg_down",C_Text_btn_bg_down);
         registerClassAlias("C_Text_btn_bg_disable",C_Text_btn_bg_disable);
         registerClassAlias("C_Text_btn_bg_disable_f",C_Text_btn_bg_disable_f);
         registerClassAlias("C_Slider_ball_disable",C4_Slider_ball_disable);
         registerClassAlias("C_Slider_ball_down",C4_Slider_ball_down);
         registerClassAlias("C_Slider_ball_over",C4_Slider_ball_over);
         registerClassAlias("C_Slider_ball_up",C4_Slider_ball_up);
         registerClassAlias("C_Sound_ball_disable",C4_Sound_ball_up);
         registerClassAlias("C_Sound_ball_down",C4_Sound_ball_down);
         registerClassAlias("C_Sound_ball_over",C4_Sound_ball_over);
         registerClassAlias("C_Sound_ball_up",C4_Sound_ball_up);
         registerClassAlias("C_Sound_icon_0_up",C4_Sound_icon_0_up);
         registerClassAlias("C_Sound_icon_0_over",C4_Sound_icon_0_over);
         registerClassAlias("C_Sound_icon_0_down",C4_Sound_icon_0_down);
         registerClassAlias("C_Sound_icon_0_disable",C4_Sound_icon_0_disable);
         registerClassAlias("C_Sound_icon_1_up",C4_Sound_icon_1_up);
         registerClassAlias("C_Sound_icon_1_over",C4_Sound_icon_1_over);
         registerClassAlias("C_Sound_icon_1_down",C4_Sound_icon_1_down);
         registerClassAlias("C_Sound_icon_1_disable",C4_Sound_icon_1_disable);
         registerClassAlias("C_Sound_icon_2_up",C4_Sound_icon_2_up);
         registerClassAlias("C_Sound_icon_2_over",C4_Sound_icon_2_over);
         registerClassAlias("C_Sound_icon_2_down",C4_Sound_icon_2_down);
         registerClassAlias("C_Sound_icon_2_disable",C4_Sound_icon_2_disable);
         registerClassAlias("C_Sound_slider",C4_Sound_slider);
         registerClassAlias("C_SysSettings_disable",C4_SysSettings_disable);
         registerClassAlias("C_SysSettings_down",C4_SysSettings_down);
         registerClassAlias("C_SysSettings_over",C4_SysSettings_over);
         registerClassAlias("C_SysSettings_up",C4_SysSettings_up);
         registerClassAlias("C_SysSettings_disable_f",C4_SysSettings_disable_f);
         registerClassAlias("C_SingleRepeat_up",C4_SingleRepeat_up);
         registerClassAlias("C_SingleRepeat_over",C4_SingleRepeat_over);
         registerClassAlias("C_SingleRepeat_down",C4_SingleRepeat_down);
         registerClassAlias("C_SingleRepeat_disable",C4_SingleRepeat_disable);
         registerClassAlias("C_SingleRepeat_disable_f",C4_SingleRepeat_disable_f);
         registerClassAlias("C_SingleRepeat_selected_up",C4_SingleRepeat_high);
         registerClassAlias("C_SingleRepeat_selected_over",C4_SingleRepeat_over);
         registerClassAlias("C_SingleRepeat_selected_down",C4_SingleRepeat_down);
         registerClassAlias("C_rotate_icon_up",C4_rotate_icon_up);
         registerClassAlias("C_rotate_icon_over",C4_rotate_icon_over);
         registerClassAlias("C_rotate_icon_down",C4_rotate_icon_down);
         registerClassAlias("C_rotate_icon_disable",C4_rotate_icon_disable);
         registerClassAlias("C_rotate_icon_disable_f",C4_rotate_icon_disable_f);
         registerClassAlias("C_Jump_Point_disable",C4_Jump_Point_up);
         registerClassAlias("C_Jump_Point_down",C4_Jump_Point_up);
         registerClassAlias("C_Jump_Point_over",C4_Jump_Point_up);
         registerClassAlias("C_Jump_Point_up",C4_Jump_Point_up);
         registerClassAlias("C_Slider_play_disable",C4_Slider_play_disable);
         registerClassAlias("C_Slider_play_down",C4_Slider_play_down);
         registerClassAlias("C_Slider_play_over",C4_Slider_play_over);
         registerClassAlias("C_Slider_play_up",C4_Slider_play_up);
         registerClassAlias("C_Slider_pause_disable",C4_Slider_pause_disable);
         registerClassAlias("C_Slider_pause_down",C4_Slider_pause_down);
         registerClassAlias("C_Slider_pause_over",C4_Slider_pause_over);
         registerClassAlias("C_Slider_pause_up",C4_Slider_pause_up);
         registerClassAlias("C_Sound2_ball_disable",C4_Sound_ball_up);
         registerClassAlias("C_Sound2_ball_down",C4_Sound_ball_down);
         registerClassAlias("C_Sound2_ball_over",C4_Sound_ball_over);
         registerClassAlias("C_Sound2_ball_up",C4_Sound_ball_up);
         registerClassAlias("C_Sound2_bg",C4_Sound2_bg);
         registerClassAlias("C_Sound2_slider",C4_Sound_slider);
         registerClassAlias("C_Sound2_icon_0",C4_Sound2_icon_0);
         registerClassAlias("C_Sound2_icon_1",C4_Sound2_icon_1);
         registerClassAlias("C_Slider_bar_grey",C4_Slider_bar_grey);
         registerClassAlias("C_Slider_bar_red",C4_Slider_bar_red);
         registerClassAlias("C_Slider_bar_buff",C4_Slider_bar_buff);
         registerClassAlias("C_Logo_symbol_up",C4_logo_color);
         registerClassAlias("C_Logo_symbol_over",C4_logo_color);
         registerClassAlias("C_Logo_symbol_down",C4_logo_color);
         registerClassAlias("C_Logo_symbol_disable",C4_logo_color);
         registerClassAlias("C4_Share_up",C4_Share_up);
         registerClassAlias("C4_Share_over",C4_Share_over);
         registerClassAlias("C4_Share_down",C4_Share_down);
         registerClassAlias("C4_Share_disable",C4_Share_disable);
         registerClassAlias("C4_Share_disable_f",C4_Share_disable_f);
         registerClassAlias("C_Preview_border",C_Preview_border);
         registerClassAlias("P_share_up",P_share_up);
         registerClassAlias("P_share_over",P_share_over);
         registerClassAlias("P_share_down",P_share_down);
      }
   }
}
